<?php

namespace App\Http\Controllers\Api;

use App\Http\Controllers\BaseController;
use Illuminate\Http\Request;

class ReportController extends BaseController
{
    public $validate = [
        "add" => ["rules" => [
            "category_id" => "required|string",
            "content" => "max:800",
            "target_id" => "required|string|max:24",
            "target_type" => "required|string|max:11",
        ]],
    ];

    /**
     * @path /report/list
     * @category 举报
     * @title 列表
     * @method POST
     * @params [{"name":"is_tort","type":"text","required":1,"example":"","desc":"是否包含【涉及侵权】选项，0否，1是"}]
     * @resBody {"success":true,"statusCode":200,"message":"操作成功","result":{"have_more":false,"list":[{"id":1,"name":"恐怖血腥","is_tort":0},{"id":2,"name":"色情低俗","is_tort":0},{"id":3,"name":"标题/封面党","is_tort":0},{"id":4,"name":"违禁内容","is_tort":0},{"id":5,"name":"涉及侵权","is_tort":1},{"id":6,"name":"其他","is_tort":0}]}}
     */
    public function getList(Request $request)
    {
        $params = $request->all();

        $data = service()->ReportService->getReportCategoryList($this->getBaseInfo($params));

        return $this->apiReturn($data);
    }

    /**
     * @path /report/add
     * @category 举报
     * @title 【有备注】新增
     * @method POST
     * @params [{"name":"category_id","type":"text","required":1,"example":"","desc":"举报类型ID"},{"name":"target_id","type":"text","required":1,"example":"","desc":"主体ID"},{"name":"target_type","type":"text","required":1,"example":"","desc":"主体类型"},{"name":"content","type":"text","required":0,"example":"","desc":"举报内容"}]
     * @resBody {"success":true,"statusCode":200,"result":true,"message":"OK"}
     * @description 1.【前端】主体，举报动态 = 举报动态主体，如举报文章动态 = 举报文章，所以没有target_type = 5
     */
    public function add(Request $request)
    {
        $params = $request->all();

        $data = service()->ReportService->addReport($this->getBaseInfo($params));
        $data = $data ? true : false;

        return $this->apiReturn($data);
    }
}
